add title, expired_at

FFIB 5 年之前
父节点
当前提交
2a2b2994c6
共有 4 个文件被更改,包括 50 次插入0 次删除
  1. 1 0
      api/pack_views.py
  2. 23 0
      goods/migrations/0002_auto_20200422_1105.py
  3. 18 0
      goods/migrations/0003_auto_20200422_1110.py
  4. 8 0
      goods/models.py

+ 1 - 0
api/pack_views.py

@@ -30,6 +30,7 @@ def pack_detail(request):
30 30
 
31 31
     return response(data={
32 32
         'kol': kol.data,
33
+        'pack': pack.data,
33 34
         'goods': goods,
34 35
         'sales': sales,
35 36
     })

+ 23 - 0
goods/migrations/0002_auto_20200422_1105.py

@@ -0,0 +1,23 @@
1
+# Generated by Django 2.2.12 on 2020-04-22 03:05
2
+
3
+from django.db import migrations, models
4
+
5
+
6
+class Migration(migrations.Migration):
7
+
8
+    dependencies = [
9
+        ('goods', '0001_initial'),
10
+    ]
11
+
12
+    operations = [
13
+        migrations.AddField(
14
+            model_name='packinfo',
15
+            name='expired_at',
16
+            field=models.DateTimeField(blank=True, help_text='创建时间', null=True, verbose_name='created_at'),
17
+        ),
18
+        migrations.AddField(
19
+            model_name='packinfo',
20
+            name='title',
21
+            field=models.CharField(blank=True, db_index=True, help_text='标题', max_length=32, null=True, verbose_name='title'),
22
+        ),
23
+    ]

+ 18 - 0
goods/migrations/0003_auto_20200422_1110.py

@@ -0,0 +1,18 @@
1
+# Generated by Django 2.2.12 on 2020-04-22 03:10
2
+
3
+from django.db import migrations, models
4
+
5
+
6
+class Migration(migrations.Migration):
7
+
8
+    dependencies = [
9
+        ('goods', '0002_auto_20200422_1105'),
10
+    ]
11
+
12
+    operations = [
13
+        migrations.AlterField(
14
+            model_name='packinfo',
15
+            name='expired_at',
16
+            field=models.DateTimeField(blank=True, help_text='创建时间', null=True, verbose_name='expired_at'),
17
+        ),
18
+    ]

+ 8 - 0
goods/models.py

@@ -46,6 +46,8 @@ class GoodsInfo(BaseModelMixin):
46 46
 
47 47
 class PackInfo(BaseModelMixin):
48 48
     pack_id = ShortUUIDField(_('pack_id'), max_length=32, blank=True, null=True, help_text='包唯一标识', db_index=True, unique=True)
49
+    title = models.CharField(_('title'), max_length=32, blank=True, null=True, help_text='标题', db_index=True)
50
+    expired_at = models.DateTimeField(_(u'expired_at'), blank=True, null=True, help_text=_(u'过期时间'))
49 51
     kol_id = models.CharField(_('kol_id'), max_length=32, blank=True, null=True, help_text='KOL 唯一标识', db_index=True)
50 52
 
51 53
     class Meta:
@@ -55,6 +57,12 @@ class PackInfo(BaseModelMixin):
55 57
     def __unicode__(self):
56 58
         return self.pk
57 59
 
60
+    @property
61
+    def data(self):
62
+        return {
63
+            'title': self.title,
64
+            'expired_at': tc.local_string(self.expired_at, format='%Y-%m-%d %H:%M'),
65
+        }
58 66
 
59 67
 class PackGoodsInfo(BaseModelMixin):
60 68
     pack_id = models.CharField(_('pack_id'), max_length=32, blank=True, null=True, help_text='包唯一标识', db_index=True)